<div class="g12 nodrop" style="margin-bottom: 43px;">

    <h1> <? if (isset($mediadata)) {echo 'Ažuriranje medije'; } else echo 'Nova medija' ?> </h1>

     <p style="line-height: 13px;">

        <? 
        
            switch($_GET['type']){
            
            case 'img': echo 'Fotografija'; break;
            case 'yt': echo 'YouToube video'; break;
            
        }     
         ?>

    </p>


    <? if (isset($mediadata)==false){ ?>

        <ul class="breadcrumb" data-connect="breadcrumbcontent">

            <li><a class="active" href="javascript:"><span>Fotografija</span></a></li>
            <li><a href="<?=$url?>media/newform?type=yt"><span>YouTube Video</span></a></li>

        </ul>

        <?}?>

    <!--FORM IMAGE-->    
    <div style="width: 100%;">

        <div id="srvrserror-3"></div>

        <button id="dialog_confirm" style="display: none;">Confirm Dialog (confirm)</button>

        <form action="javascript:" method="post" autocomplete="off" data-confirm-send="false" id="frm_img">

            <fieldset>

                <section><label for="input">Naziv</label>
                    <div><input type="text" id="name" name="name" required value="<? if (isset($mediadata)) echo $mediadata[0]['name']; ?>"></div>
                </section>

                <section><label for="input">Opis - (Interni text za laksu identifikaciju)</label>
                    <div><input type="text" id="description" name="description" required value="<? if (isset($mediadata)) echo $mediadata[0]['description']; ?>"></div>
                </section>

                <section><label for="input">Autor</label>
                    <div><input type="text" id="author" name="author" required value="<? if (isset($mediadata)) echo $mediadata[0]['author']; ?>"></div>
                </section>

                <section><label for="input">Direktorijum</label>
                    <div>
                        <select name="directory" id="directory" style="color: #555555; line-height: 16px; padding: 3px 0 0 3px; width: 17em;">
                            <option value="0">-- Molim odaberite</option> 
                            <?
                                foreach($directoryMedia as $directory){

                                ?><option value="<?=$directory['id'];?>" <? if(isset($mediadata)){if(($mediadata[0]['directory_id']==$directory['id'])){ echo 'selected=selected';}} ?>><?=$directory['name'];?></option><?

                                }
                            ?>
                        </select>
                    </div>
                </section>

                <section><label for="input">Upload fajla</label>
                    <div>
                        <table style="background: none;">
                            <tr>
                                <td style="width: 300px; text-align: left; vertical-align: top;">
                                    <div id="uploader">
                                        <div id="filelist"></div>
                                        <br />

                                        <a id="pickfiles" href="javascript:">[Dodaj fajl]</a> |
                                        <a id="uploadfiles" href="javascript:">[Start Upload]</a> 

                                    </div>   
                                </td>
                                <td style="">
                                    <div id="displayImage" style="float: left; width: 70px; <? if (!isset($mediadata)) echo "display: none;"; ?>">

                                        <img src="<? if (isset($mediadata)) echo $url.'tempatt/'.$mediadata[0]['file']; ?>" width="110" />

                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </section>

                <section><label for="input">Tagovi</label>
                    <div><input type="text" id="tags" name="tags" required value="<? if (isset($mediadata)) echo $mediadata[0]['tags']; ?>"></div>
                </section>

                <input type="hidden" name="filename" id="filename" value="<? if (isset($mediadata)) echo $mediadata[0]['file']; ?>" />
                <input type="hidden" name="type" id="type" value="img" />

                <section>
                    <button class="submit small" onclick="return false;"><? if (isset($mediadata[0]['name'])) {echo 'Ažuriraj Mediju'; }else echo 'Kreiraj mediju'; ?></button>
                </section> 

            </fieldset>

        </form>

    </div>


</div>

<!-- VARIABLES TO edit_new_img.js -->
<script type="text/javascript">
    var appmode;
    var get_id;
    <?  if (isset($_GET['id'])){ ?> 
        appmode = 'edit';
        get_id = '<?=$_GET['id']?>';

        <?}else{?> 
        appmode = 'insert'; 
        get_id = -1;
        <? } ?>
</script>
<style>
    #uniform-directory span{
        width: 17em;
    }
</style>